package net.zwj.hadoop.mapred;

import java.io.IOException;
import java.net.URI;

import org.apache.commons.lang.math.RandomUtils;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.IOUtils;

public class DemoFileCreator {

	public static void main(String[] args) throws IOException, InterruptedException {
		String uri = "/testfile";
		Configuration conf = new Configuration();
		
		FileSystem fs= FileSystem.get(URI.create(uri), conf, "hadoop");
		FSDataOutputStream out = fs.create(new Path(uri), true);
		String str = null;
		int a,b;
		for(int i=0;i<10000;i++){
			a = RandomUtils.nextInt(10);
			b = RandomUtils.nextInt(100);
			str = (2000+a)+" "+b+"\n";
			out.write(str.getBytes());
		}
//		out.write(b);
		out.flush();		
		IOUtils.closeStream(out);
		
	}

}
